package com.netease.nim.uikit.session.activity.Evaluate;

import android.content.Context;
import android.media.session.MediaSession;

import com.loopj.android.http.RequestParams;
import com.netease.nim.uikit.MV.BasePresenter;
import com.netease.nim.uikit.MV.BusinessClient;
import com.netease.nim.uikit.MV.ConstantValueWYY;
import com.netease.nim.uikit.MV.MyHttpResponseHandler;
import com.netease.nim.uikit.MV.Response;
import com.netease.nim.uikit.MV.Utils.Util;

import org.apache.http.Header;

/**
 * Created by Administrator on 2016/4/14.
 */
public class EvaluatePresenter extends BasePresenter {

    private EvaluateView view;

    public EvaluatePresenter(Context context, EvaluateView view) {
        super(context, view);
        this.view = view;
    }

    public void submitevaluate(String hosId, int point, String remark, String recId, String userid, String token) {
        RequestParams params = new RequestParams();
        params.put("hosId", hosId);
        params.put("point", Util.toString(point));
        params.put("remark", remark);
        params.put("recId", recId);
        params.put("userId", userid);
        params.put("token", token);
        BusinessClient.post(ConstantValueWYY.submitimpress, params, new MyHttpResponseHandler() {
            @Override
            public void onMyResponse(Response response) {
                if (response.isSucceed()) {
                    view.submitsucced();
                } else {
                    view.showToastMessage(response.getMsg());
                    view.submitfail();
                }
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                super.onFailure(i, headers, bytes, throwable);
                view.submitfail();
            }
        });
    }
}
